package conf

import (
	"github.com/rs/zerolog"
	"gopkg.in/yaml.v3"
)

type Config struct {
	MySQL       *mySQL       `json:"mysql" yaml:"mysql"`
	MongoDB     *mongoDB     `json:"mongodb" yaml:"mongodb"`
	Application *application `json:"application" yaml:"aplication"`

	Log *Log `json:"log" yaml:"log"`
}

func Default() *Config {
	return &Config{
		MySQL:       MySQL(),
		MongoDB:     MongoDB(),
		Application: Application(),
		Log: &Log{
			CallerDeep: 3,
			Level:      zerolog.ErrorLevel,
			Console: Console{
				Enable:  true,
				NoColor: false,
			},
			File: File{
				Enable:     true,
				MaxSize:    100,
				MaxBackups: 3,
			},
		},
	}
}

func (c *Config) ToYAML() string {
	out, err := yaml.Marshal(c)
	if err != nil {
		panic(err)
	}
	return string(out)
}
